package jlb.andriva.wrappers;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import jlb.andriva.R;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

public class Util {

	public static void goToNativa(Context context) {
		String url = context.getResources().getString(R.string.nativa_url);
		Uri uriUrl = Uri.parse(url);
		Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); 
		context.startActivity(launchBrowser);
	}
	
	public static void ShowToast(Context context, String mess){
		Toast toast = Toast.makeText(context, mess, Toast.LENGTH_LONG);
        toast.show(); 
	}
	
	public static String getRawContent(Context context, int rawId){
		InputStream inputStream = context.getResources().openRawResource(rawId);
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		int i;
		try {
		i = inputStream.read();
		while (i != -1){
			byteArrayOutputStream.write(i);
			i = inputStream.read();
		}
		inputStream.close();
		} catch (IOException e) {
			return "";
		}
		return byteArrayOutputStream.toString();
	}
}